home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / M&T Graphics & Sound Examples / Metrowerks Versions / C07 QuickTime Movies / P01 Quick Play Movie / QuickPlay.c next >
Encoding:
C/C++ Source or Header  |  1995-08-05  |  2.4 KB  |  103 lines  |  [TEXT/MMCC]

  1. //____________________________________________________________
  2. //    QuickPlay.c
  3. //
  4. //    Copyright © Dan Parks Sydow, 1995
  5. //    From the book:
  6. //    "Graphics and Sound Programming Techniques for the Mac",
  7. //    M&T Books, 1995
  8.  
  9.  
  10. //____________________________________________________________
  11.  
  12. #include <Movies.h>   
  13. #include <Gestalt.h>
  14.  
  15.  
  16. //____________________________________________________________
  17.  
  18. void  InitializeAllToolboxes( void );
  19.  
  20.  
  21. //____________________________________________________________
  22.  
  23. #define      rMovieWindow            128
  24. #define      kMovieName         "\pRobot"
  25.  
  26.  
  27. //____________________________________________________________
  28.  
  29. void  main( void )
  30.    OSErr      theError;
  31.    FSSpec     theFSSpec;
  32.    short      theFileRefNum;
  33.    Movie      theMovie;
  34.    short      theMovieResID = 0;   
  35.    Str255     theMovieResName;
  36.    Boolean    wasAltered;
  37.    WindowPtr  theWindow;
  38.    Rect       theMovieBox;
  39.  
  40.    InitializeAllToolboxes();
  41.    
  42.    theError = FSMakeFSSpec( 0, 0, kMovieName, &theFSSpec );
  43.    theError = OpenMovieFile( &theFSSpec, &theFileRefNum, fsRdPerm );
  44.    theError = NewMovieFromFile( &theMovie, theFileRefNum, &theMovieResID,
  45.                                  theMovieResName, newMovieActive, &wasAltered );
  46.                                          
  47.    CloseMovieFile( theFileRefNum );
  48.    
  49.    theWindow = GetNewCWindow( rMovieWindow, nil, (WindowPtr)-1L );   
  50.  
  51.    SetMovieGWorld( theMovie, (CGrafPtr)theWindow, nil );   
  52.  
  53.    GetMovieBox( theMovie, &theMovieBox );
  54.    OffsetRect( &theMovieBox, -theMovieBox.left, -theMovieBox.top );
  55.    SetMovieBox( theMovie, &theMovieBox );
  56.  
  57.    SizeWindow( theWindow, theMovieBox.right, theMovieBox.bottom, true );  
  58.    ShowWindow( theWindow);
  59.  
  60.    GoToBeginningOfMovie( theMovie );
  61.  
  62.    StartMovie( theMovie );
  63.  
  64.    do
  65.    {
  66.       MoviesTask(theMovie, 0);
  67.    }
  68.    while ( IsMovieDone( theMovie ) == false );
  69.    
  70.    DisposeMovie( theMovie );
  71.    DisposeWindow( theWindow );
  72. }
  73.  
  74.  
  75. //____________________________________________________________
  76.  
  77. void  InitializeAllToolboxes( void )
  78. {
  79.    OSErr  theError;
  80.    long   theResult;
  81.  
  82.    InitGraf( &qd.thePort );
  83.    InitFonts();
  84.    InitWindows();
  85.    InitMenus();
  86.    TEInit();
  87.    InitDialogs( 0L );
  88.    FlushEvents( everyEvent, 0 );
  89.    InitCursor();
  90.  
  91.    theError = Gestalt( gestaltQuickTime, &theResult );
  92.    if ( theError != noErr )
  93.       ExitToShell();
  94.                                                  
  95.    theError = EnterMovies();  
  96.    if ( theError != noErr )
  97.       ExitToShell(); 
  98. }
  99.  
  100.  
  101.  
  102.